<Query Kind="Program" />

void Main()
{


	// Convert.ChangeType("false",typeof(bool?))
	//Console.Write(typeof(bool?));
	Console.Write(Nullable.GetUnderlyingType(typeof(bool?)));
	
	changType();
}

// Define other methods and classes here
private void changType(){
//  Convert.ChangeType() fails on Nullable Types
//        https://stackoverflow.com/questions/3531318/convert-changetype-fails-on-nullable-types

	Xx source = new Xx(){IsTrue = false};
	var pi = source.GetType().GetProperty("IsTrue");
	var pType = pi.PropertyType;
	pType = Nullable.GetUnderlyingType(pType) ?? pType;
	var pVal = pi.GetValue(source, null);
	var value = pVal == null ? null : Convert.ChangeType(pVal, pType);	
	Console.WriteLine(value);
}

class Xx{
   public bool? IsTrue {get;set;} 
}
